package com.br.modelo.dao;

import java.util.List;
import com.br.modelo.entidades.Status;

public class StatusDao {
	private DaoResource daoResource = new DaoResource();
	private Status status = new Status();

	public void saveStatus(String stat) {
		status.setStatus(stat);

		daoResource.save(status);
	}

	public void updateStatus(int cdStatus, String stat) {
		List<Status> st = daoResource.select("from Status where cdStatus = :id", "id", cdStatus);

		st.get(0).setStatus(stat);

		daoResource.save(st.get(0));
	}

	public void baixaStatus(int cdStatus) {
		List<Status> st = daoResource.select("from Status where cdStatus = :id", "id", cdStatus);

		st.get(0).setInvalido("s");

		daoResource.save(st.get(0));
	}
	
	public void endConnection() {
		daoResource.endConnection();
	}
	
	public List<Status> listaStatusAtivo() {
		List<Status> stat = daoResource.select("from Status where invalido = null");
		return stat;
	}
	
	public List<Status> listaStatusTudo() {
		List<Status> stat = daoResource.select("from Status");
		return stat;
	}
}

